using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.ComponentModel;

namespace Mdv.wssAddins.wss
{
    public class wssFields : Model
    {
        #region Non-Designer Properties
        private List<wssField> _fields;
        [Browsable(false)]
        public List<wssField> Fields
        {
            get { return _fields; }
        }
        #endregion
        public override string ToString()
        {
            return "Fields";
        }
        public override void ConstructMap()
        {
        }
        public override void LoadChildren(XmlNode node)
        {
            foreach (XmlNode xn in node.ChildNodes)
            {
                switch (xn.Name)
                {
                    case "Field":
                        wssField field = new wssField();
                        field.Load(xn);
                        Children.Add(field);
                        break;
                }
            }
        }
        public wssFields()
        {
            Actions = new List<Action>();
            Actions.Add(new Action( "Add Field", this.AddField));
            Actions.Add(new Action("Add FieldRef", this.AddFieldRef));
            Actions.Add(new Action("Delete", this.Delete));
        }
        public void AddField(ModelEventArgs e)
        {
            NodeAdded(new wssField(), "Field");
        }
        public void AddFieldRef(ModelEventArgs e)
        {
            NodeAdded(new wssFieldRef(), "FieldRef");
        }
        public void Delete(ModelEventArgs e)
        {
            NodeDeleted("Fields");
        }
    }
}